/*
 * LinkMediaSink.h
 *
 *  Created on: 2020年8月15日
 *      Author: chuan
 */

#ifndef INCLUDE_LINKMEDIASINK_H_
#define INCLUDE_LINKMEDIASINK_H_

#include "UMediaSource.h"

class LinkMediaSink : public UMediaSink
{
public:
    explicit LinkMediaSink(UMediaSink* pSink):
        m_sink(pSink)
    {
    }

    virtual ~LinkMediaSink()
    {

    }

    void resetSink(UMediaSink* pSink)
    {
        m_sink = pSink;
    }

    virtual void onMediaFormat(const UMediaFormat& fmt)
    {
        if (m_sink)
        {
            m_sink->onMediaFormat(fmt);
        }
    }

    virtual void onMediaPacket(UMediaPacket& pkt)
    {
        fireMediaPacket(pkt);
    }

    virtual void onMediaEvent(int event)
    {
        if (m_sink)
        {
            m_sink->onMediaEvent(event);
        }
    }

protected:
    void fireMediaPacket(UMediaPacket& pkt)
    {
        if (m_sink)
        {
            m_sink->onMediaPacket(pkt);
        }
    }

protected:
    UMediaSink*  m_sink;

};


#endif /* INCLUDE_LINKMEDIASINK_H_ */
